package com.example.jurisdiction.Service.impl;

import java.util.List;

import com.example.jurisdiction.Mapper.pageMapper;
import com.example.jurisdiction.Service.pageService;
import entity.PageBean;
import entity.jurisdiction;
import entity.role;
import entity.sys_user_info;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class pageServiceimpl implements pageService {

	@Autowired
	private pageMapper rolesDao;
	//角色
	@Override
	public PageBean getAllRole(Integer currentPage, Integer pageSize, String name) throws Exception {
		
		if(currentPage==null) {
			currentPage=1;
		}
		int rowCount=this.rolesDao.getRowCounts(name);
		System.out.println(currentPage+"-----"+pageSize);
		//pageSize=5;
		//rowCount=20;
		PageBean pageBean=new PageBean(currentPage, pageSize, rowCount,name);
		
		System.out.println("开"+pageBean.getStartIndex());
		System.out.println("结"+pageBean.getEndIndex());
	    List<role> user= this.rolesDao.getAllRole(pageBean);
	    pageBean.setData(user);
		return pageBean;
	}

	@Override
	public List<role> getAllRoles() throws Exception {
		// TODO Auto-generated method stub
		return this.rolesDao.getAllRoles();
	}
	//用户
	@Override
	public PageBean getAllUser(Integer currentPage,Integer pageSize,String name) throws Exception {
		
		if(currentPage==null) {
			currentPage=1;
		}
		int rowCount=this.rolesDao.getUserCounts(name);
		System.out.println(currentPage+"-----"+pageSize);
		//pageSize=5;
		//rowCount=20;
		PageBean pageBean=new PageBean(currentPage, pageSize, rowCount,name);
		
		System.out.println("开"+pageBean.getStartIndex());
		System.out.println("结"+pageBean.getEndIndex());
	    List<sys_user_info> role= this.rolesDao.getAllUser(pageBean);
	    pageBean.setData(role);
		return pageBean;
	}

	@Override
	public List<sys_user_info> getAllUsers() throws Exception {
		// TODO Auto-generated method stub
		return this.rolesDao.getAllUsers();
	}
	//菜单
	@Override
	public PageBean getAlljurisdiction(Integer currentPage,Integer pageSize,String name) throws Exception {
		
		if(currentPage==null) {
			currentPage=1;
		}
		int rowCount=this.rolesDao.getRowjurisdiction(name);
		System.out.println(currentPage+"-----"+pageSize);
		//pageSize=5;
		//rowCount=20;
	System.out.println("总行数"+rowCount);
		PageBean pageBean=new PageBean(currentPage, pageSize, rowCount,name);
		
		System.out.println("开"+pageBean.getStartIndex());
		System.out.println("结"+pageBean.getEndIndex());
	    List<jurisdiction> jurisdiction= this.rolesDao.getAlljurisdiction(pageBean);
	    pageBean.setData(jurisdiction);
		return pageBean;
	}

	@Override
	public List<jurisdiction> getAlljurisdictions() throws Exception {
		// TODO Auto-generated method stub
		return this.rolesDao.getAlljurisdictions();
	}




}
